import React from 'react'
import AsyncComponent from './AsyncComponent'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import Home from 'containers/home'

const routes = [{
  path: '/',
  component: Home
}, {
  path: '/talent',
  component: props => AsyncComponent(props, () => import('containers/home/talent'))
}, {
  path: '/post',
  component: props => AsyncComponent(props, () => import('containers/post'))
}, {
  path: '/myPost',
  component: props => AsyncComponent(props, () => import('containers/post/myPost'))
}, {
  path: '/myCollection',
  component: props => AsyncComponent(props, () => import('containers/post/myCollection'))
}, {
  path: '/topPost',
  component: props => AsyncComponent(props, () => import('containers/post/topPost'))
}, {
  path: '/mainText',
  component: props => AsyncComponent(props, () => import('containers/post/mainText'))
}, {
  path: '/activity',
  component: props => AsyncComponent(props, () => import('containers/post/activity'))
}, {
  path: '/mine',
  component: props => AsyncComponent(props, () => import('containers/mine'))
}, {
  path: '/userInformation',
  component: props => AsyncComponent(props, () => import('containers/mine/userInformation'))
}, {
  path: '/about',
  component: props => AsyncComponent(props, () => import('containers/mine/about'))
}, {
  path: '/feedBack',
  component: props => AsyncComponent(props, () => import('containers/mine/feedBack'))
}, {
  path: '/systemMsg',
  component: props => AsyncComponent(props, () => import('containers/mine/systemMsg'))
}, {
  path: '/myBean',
  component: props => AsyncComponent(props, () => import('containers/mine/myBean'))
}, {
  path: '/beanRule',
  component: props => AsyncComponent(props, () => import('containers/mine/beanRule'))
}, {
  path: '/myReply',
  component: props => AsyncComponent(props, () => import('containers/mine/myReply'))
}, {
  path: '/replyMe',
  component: props => AsyncComponent(props, () => import('containers/mine/replyMe'))
}, {
  path: '/article',
  component: props => AsyncComponent(props, () => import('containers/article'))
}]

const RouteConfig = (
  <BrowserRouter>
    <Switch>
      { routes.map((route, index) => {
        return <Route
          key={index}
          path={route.path}
          exact={index === 0}
          component={route.component} />
      })}
    </Switch>
  </BrowserRouter>
)

export default RouteConfig
